<%@ page import="java.util.HashMap" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>


<html>
<head>
    <title>欢迎</title>
</head>
<style>
    body {
        font-family: Arial, sans-serif;
        margin: 0;
        padding: 0;
        background-color: #f5f5f5;
    }
    .header {
        background-color: #ff5000;
        color: white;
        padding: 10px;
        text-align: center;
    }
    .sidebar {
        width: 200px;
        background-color: #fff;
        position: fixed;
        height: 100%;
        overflow: auto;
    }
    .sidebar a {
        display: block;
        color: black;
        padding: 16px;
        text-decoration: none;
    }
    .sidebar a.active {
        background-color: #4CAF50;
        color: white;
    }
    .sidebar a:hover:not(.active) {
        background-color: #555;
        color: white;
    }
    .content {
        margin-left: 200px;
        padding: 20px;
    }
    .user-info {
        display: flex;
        align-items: center;
        background-color: #fff;
        padding: 20px;
        border-bottom: 1px solid #e5e5e5;
    }
    .user-info img {
        border-radius: 50%;
        margin-right: 20px;
    }
    .user-info div {
        flex-grow: 1;
    }
    .products {
        display: flex;
        flex-wrap: wrap;
        margin-top: 20px;
    }
    .product {
        width: 23%;
        margin: 1%;
        padding: 10px;
        border: 1px solid #ccc;
        border-radius: 4px;
        background-color: #ffffff;
    }
    .product img {
        width: 100%;
        height: auto;
    }
</style>

<body>
<%-- 检查 session 是否为空 --%>
    <%
    // 检查 session 中是否存在 "user" 属性
    if (session.getAttribute("user") == null) {
%>
<a href="${pageContext.request.contextPath}/login.jsp">账号未登录，请登录！</a>
    <%
} else {
    // 将 user 对象从 session 中取出并转换为 HashMap
    HashMap<String, String> user = (HashMap<String, String>) session.getAttribute("user");
%>
<div class="header">
    <h1>淘宝</h1>
</div>
<div class="sidebar">
    <a href="#" class="active">我的淘宝</a>
    <a href="${pageContext.request.contextPath}/CartServlet" target="_blank">我的购物车</a>
    <a class="nav-tab" href="${pageContext.request.contextPath}/OrderServlet" target="_blank">我的订单</a>
    <a href="${pageContext.request.contextPath}/force">宝贝收藏</a>
    <!--<a href="#">评价管理</a>-->
    <a href="#">账户设置</a>
</div>
<div class="content">
    <div class="user-info">
        <img src="pic.jpg" alt="pic" style="width:50px;">
        <div>
            <h2>欢迎, ${user.get("username")}</h2>
            <p>用户ID: ${user.get("userId")}</p>
            <p>角色权限: ${user.get("roleId")}</p>
            <p>性别: ${user.get("sex")}</p>
            <p>联系人: ${user.get("peiceName")}</p>
            <p>电话: ${user.get("phone")}</p>
            <p>省份: ${user.get("province")}</p>
            <p>地区: ${user.get("district")}</p>
            <p>详细地址: ${user.get("detailAddress")}</p>

        </div>
    </div>
</div>

    <%
    }
%>
</html>